#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int n = 0, x;
    scanf("%d", &n);
    int arr[51] = { 0 };
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);
    scanf("%d", &x);
    for (int i = n - 1; i >= 0; i--)
    {
        if (x > arr[i])
        {
            arr[i + 1] = x;
            break;
        }   arr[i + 1] = arr[i];
    }
    for (int i = 0; i <= n; i++)
        printf("%d ", arr[i]);
    return 0;
}